package com.gltc.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.gltc.entities.PhotoAuthUser;

public interface PhotoAuthUserDao {

	@Select("select * from photo_auth_user where username = #{username} and password = MD5(#{password})")
	public PhotoAuthUser getUserByLoginNameAndPass(PhotoAuthUser userLogReg);

	@Select("select * from photo_auth_user where username = #{username}")
	public PhotoAuthUser getUserByLoginName(@Param("username")String username);
	
	 @Insert("insert into photo_auth_user (username, "
	        + "password, isadmin)"
	        + "values (#{username,jdbcType=VARCHAR}, MD5(#{password,jdbcType=VARCHAR}), "
	        + "#{isadmin,jdbcType=INTEGER})"
	        )
	 boolean insertUser(PhotoAuthUser userLogReg);

	 @Update("update photo_auth_user set logintime = #{formatDateTime} where id = #{id}")
	public void updateUserLoginTime(@Param("id")int id, @Param("formatDateTime")String formatDateTime);
}
